//
//  ClockTypeOneViewController.m
//  SpecialEffectsProject
//
//  Created by 蓓蕾 on 2021/11/4.
//

#import "ClockTypeOneViewController.h"
#import "ClockView.h"

@interface ClockTypeOneViewController ()

@property (nonatomic,strong) ClockView *clock;

@end

@implementation ClockTypeOneViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    [self createClockView];
}

-(void)createClockView
{

    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(kScreenWidth / 2 - 160 / 2,64 + 20, 160, 30);
//    button.center = CGPointMake(kScreenWidth/2, kScreenWidth/6);
    [button setTitle:@"ChangeRollStyle" forState:UIControlStateNormal];
    [button setBackgroundColor:[UIColor brownColor]];
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [button setTitleColor:[UIColor blackColor] forState:UIControlStateHighlighted];
    [button addTarget:self action:@selector(changeSecRoll) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    
    self.clock = [[ClockView alloc]initWithFrame:CGRectMake(kScreenWidth / 2 - 200 / 2, CGRectGetMaxY(button.frame) + 20, 200, 200)];
//    self.clock.center = CGPointMake(kScreenWidth/2, kScreenWidth/2);
    [self.view addSubview:self.clock];
    self.clock.secRoll = NO;
    [self.clock start];
}

// 监听按钮点击事件
- (void)changeSecRoll{

    self.clock.secRoll = !self.clock.secRoll;

}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
